package com.ndp.fb.scheduler.job.httprequest;

import com.alibaba.dubbo.config.annotation.Reference;
import com.ndp.fb.constant.ConfigConst;
import com.ndp.fb.mq.api.service.schedulerservice.HttprequestSchedulerService;
import com.ndp.fb.scheduler.annotation.CronScheduled;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.concurrent.atomic.AtomicLong;

@Component
public class HttpRequestJob {
    private static Logger logger = LoggerFactory.getLogger(HttpRequestJob.class);
    @Reference
    protected HttprequestSchedulerService httprequestService;
    AtomicLong atomicLong = new AtomicLong(0);

    /**
     * 普通请求
     */
    @CronScheduled(cronkey = ConfigConst.SCHEDULE_HTTP_REQUEST_CRON, enablekey = ConfigConst.SCHEDULE_HTTP_REQUEST_ENABLE)
    public void httpRequest() {
        long addAndGet = atomicLong.addAndGet(1);
        logger.info("httpRequest 请求开始 >>> "+ addAndGet);
        try{
            httprequestService.requestConsumer();
        } catch (Exception e){
            logger.error("xxxxx", e);
        }
    }
}
